package in.muton.edushare.components.tasks.invitations.api;

import in.muton.edushare.EduShareSession;
import in.muton.edushare.components.messaging.api.PollMessage;
import in.muton.edushare.url.EduShareURLPanel;
import in.muton.edushare.wicket.models.CayenneList;
import in.muton.edushare.wicket.models.CayenneModel;

import java.util.List;

import org.apache.wicket.model.IModel;

import com.edushare.common.dao.PollsDAO;
import com.edushare.common.dao.UserPollDAO;
import com.edushare.common.dao.UserRolesDAO;
import com.edushare.common.orm.ORMInterface;
import com.edushare.common.vo.Messages;
import com.edushare.common.vo.Poll;
import com.edushare.common.vo.Universities;
import com.edushare.common.vo.UserPoll;
import com.edushare.common.vo.UserRoles;
import com.edushare.common.vo.Users;

public class UnivInvitation extends Invitation {
	private static final long serialVersionUID = 5003579021599329374L;

	public UnivInvitation(IModel<UserRoles> invite) {
		this.invitation = invite;
	}

	@Override
	public void accept() {
		invitation.getObject().setStatus(UserRoles.STATUS_ACTIVE);
		EduShareSession.get().getSessionORMInterface().commitAllChanges();
		postInvitationTasks();
	}

	@Override
	public void decline() {
		new UserRolesDAO(EduShareSession.get().getSessionORMInterface())
				.removeUser(invitation.getObject().getUniversity(), invitation
						.getObject().getUser());
	}

	@Override
	public EduShareURLPanel getDestURL() {
		return new EduShareURLPanel("link", new CayenneModel<Universities>(
				invitation.getObject().getUniversity()));
	}

	private IModel<UserRoles> invitation;

	@Override
	public void postInvitationTasks() {
		
	}
}
